﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace CMS
{
    [Serializable]
    public class Uploads
    {

        public long? ADM_ID { get; set; }
        public long? UPL_ID { get; set; }
        public long? USR_ID { get; set; }

        public string UPL_NAME { get; set; }
        public string UPL_GUID { get; set; }
        public string UPL_COMMENTS { get; set; }

        #region Constructors
        /// <summary>
        /// Creates a new instance of an Page object.
        /// </summary>
        public Uploads() : this(null) { }

        /// <summary>
        /// Creates a new instance of an Page object.
        /// </summary>
        public Uploads(long? id)
        {
            UPL_ID = id;
        }
        #endregion

        /// <summary>
        /// Returns a list of Pages.
        /// </summary>
        public static List<CMS.Uploads> GetUpload(Int64? ADM_ID, Int64? UPL_ID, Int64? USR_ID, String UPL_NAME, String UPL_GUID, String UPL_COMMENTS)
        {
            DataTable StoredProcedureTablePages = CMS.StoredProcedureValues.VW_Upload(ADM_ID, UPL_ID, USR_ID, UPL_NAME, UPL_GUID, UPL_COMMENTS);
            return GetListUpload(StoredProcedureTablePages);
        }

        /// <summary>
        /// Converts a DataTable into a list of Pages.
        /// </summary>
        public static List<CMS.Uploads> GetListUpload(DataTable StoredProcedureTable)
        {
            List<CMS.Uploads> OutUpload = new List<CMS.Uploads>();

            for (int i = 0; i < StoredProcedureTable.Rows.Count; i++)
            {
                CMS.Uploads Upload = new CMS.Uploads();
                DataRow Row = StoredProcedureTable.Rows[i];

                Upload.ADM_ID = Convert.ToInt64((Row["ADM_ID"]));
                Upload.UPL_ID = Convert.ToInt64((Row["UPL_ID"]));
                Upload.USR_ID = Convert.ToInt64((Row["USR_ID"]));
                Upload.UPL_NAME = Row["UPL_NAME"].ToString();
                Upload.UPL_GUID = Row["UPL_GUID"].ToString();
                Upload.UPL_COMMENTS = Row["UPL_COMMENTS"].ToString();

                OutUpload.Add(Upload);
            }

            return OutUpload;
        }
    }
}